package com.it.commicity.controller.count;

import com.it.commicity.common.Result;
import com.it.commicity.domain.vo.count.MainWel;
import com.it.commicity.mapper.count.CountMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@RequestMapping("/api")
@RestController
public class CountController {

    @Autowired
    private CountMapper countMapper;

    @GetMapping("/welcome/selectCount")
//    @CrossOrigin
    public Result<HashMap<Object, Object>> selectWel() {
        HashMap<Object, Object> map = new HashMap<>();
        MainWel mainWel = new MainWel();
        mainWel.setVisitorNum(countMapper.selectVisitor());
        mainWel.setOwnerNum(countMapper.selectOwner());
        mainWel.setRoomNum(countMapper.selectRoom());

        map.put("code", 200);
        map.put("msg", "请求成功");
        map.put("Object", mainWel);

        return Result.success(map);
    }
}
